package com.itheima02;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class GouWu {
    public static void main(String[] args) {
        HashMap<Shopping, Integer> hm = new HashMap<>();

        Shopping s1 = new Shopping("手机", 2000);
        Shopping s2 = new Shopping("电脑", 1000);
        Shopping s3 = new Shopping("冰箱", 20000);

        hm.put(s1, 2);
        hm.put(s2, 10);
        hm.put(s3, 8);

        int sum = 0;
        Set<Map.Entry<Shopping, Integer>> entries = hm.entrySet();
        for (Map.Entry<Shopping, Integer> entry : entries) {
            Shopping key = entry.getKey();
            Integer value = entry.getValue();
            int danjia = key.getPrice() * value;
            sum += danjia;
        }
        System.out.println(sum);
    }
}
